A call-by-name lambda-calculus machine
نویسنده
چکیده
We present, in this paper, a particularly simple lazy machine which runs programs written in λ-calculus. It was introduced by the present writer more than twenty years ago. It has been, since, used and implemented by several authors, but remained unpublished. In the first section, we give a rather informal, but complete, description of the machine. In the second part, definitions are formalized, which allows us to give a proof of correctness for the execution of λterms. Finally, in the third part, we build an extension for the machine, with a control instruction (a kind of call-by-name call/cc) and with continuations. This machine uses weak head reduction to execute λ-calculus, which means that the active redex must be at the very beginning of the λterm. Thus, computation stops if there is no redex at the head of the λ-term. In fact, we reduce at once a whole chain λx1 . . . λxn. Therefore, execution also stops if there are not enough arguments. The first example of a λ-calculus machine is P. Landin’s celebrated SECD-machine [8]. The one presented here is quite different, in particular because it uses call-by-name. This needs some explanation, since functional programming languages are, most of the time, implemented through call-by-value. Here is the reason for this choice : Starting in the sixties, a fascinating domain has been growing between logic and theoretical computer science, that we can designate as the Curry-Howard correspondence. Succinctly, this correspondence permits the transformation of a mathematical proof into a program, which is written : in λ-calculus if the proof is intuitionistic and only uses logical axioms ; in λ-calculus extended with a control instruction, if one uses the law of excluded middle [4] and the axioms of Zermelo-Frænkel set theory [6], which is most often the case. Other instructions are necessary if one uses additional axioms, such as
منابع مشابه
Deriving a Lazy Abstract Machine
We derive a simple abstract machine for lazy evaluation of the lambda calculus, starting from Launchbury's natural semantics. Lazy evaluation here means non-strict evaluation with sharing of argument evaluation, that is, call-by-need. The machine we derive is a lazy version of Krivine's abstract machine, which was originally designed for call-by-name evaluation. We extend it with datatype const...
متن کاملCall-by-Name, Call-by-Value and the lambda-Calculus
This paper examines the old question of the relationship between ISWIM and the &calculus, using the distinction between call-by-value and call-by-name. It is held that the relationship should be mediated by a standardisation theorem. :3ince this leads to difficulties, a new &calcu%~s is introduced whose standardisation theorem gives a good correspondence with ISWIM a-; given by the SECT machine...
متن کاملAn Implementation of the Call-By-Name -Calculus
We describe an experimental, low-level implementation of the -calculus. The implementation is based on a Krivine-style abstract machine, which is in turns derived from a simple CPS semantics. Parigot’s -calculus was originally invented as a proof-term calculus for classical logic [2]. One can also regard it as a prototypical call-by-name programming language with control primitives. However, it...
متن کاملFrom Continuation Passing Style to Krivine’s Abstract Machine
We describe, for three different extensions of typed lambda calculus, how the rules for a version of Krivine’s abstract machine can be derived from those of continuation passing style (CPS) semantics. The three extensions are: Parigot’s λμcalculus, Pym and Ritter’s λμν-calculus, and an extension of the call-by-name lambda calculus with built-in types and primitive functions. We also show how Kr...
متن کاملA Certified Extension of the Krivine Machine for a Call-by-Name Higher-Order Imperative Language
In this paper we present a compiler that translates programs from an imperative higher-order language into a sequence of instructions for an abstract machine. We consider an extension of the Krivine machine for the call-by-name lambda calculus, which includes strict operators and imperative features. We show that the compiler is correct with respect to the big-step semantics of our language, bo...
متن کاملEquivalence of Call-By-Name and Call-By-Need for Lambda-Calculi with Letrec
We develop a proof method to show that in a (deterministic) lambda calculus with letrec and equipped with contextual equivalence the call-by-name and the call-by-need evaluation are equivalent, and also that the unrestricted copy-operation is correct. Given a let-binding x = t, the copy-operation replaces an occurrence of the variable x by the expression t, regardless of the form of t. This giv...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- Higher-Order and Symbolic Computation
دوره 20 شماره
صفحات -
تاریخ انتشار 2007